package com.stone.test;

import com.google.errorprone.annotations.Var;
import com.google.protobuf.InvalidProtocolBufferException;
import com.stone.im.common.Constants;
import com.stone.im.common.Request;
import io.netty.buffer.ByteBuf;

public class test {
    public static void main(String[] args) throws InvalidProtocolBufferException {

        AuthenticateRequestProto.AuthenticateRequest.Builder builder = AuthenticateRequestProto.AuthenticateRequest.newBuilder();
        builder.setUid("111");
        builder.setToken("token");
        builder.setTimestamp(System.currentTimeMillis());
        AuthenticateRequestProto.AuthenticateRequest authenticateRequest = builder.build();
        byte[] requestBytes = authenticateRequest.toByteArray();

        //封装完整的带消息头的认证请求
        Request request = new Request(
                Constants.APP_SDK_VERSION_1,
                Constants.REQUEST_TYPE_AUTHENTICATE,
                Constants.SEQUENCE_DEFAULT,
                requestBytes
                );

        AuthenticateRequestProto.AuthenticateRequest authenticateRequest1 = AuthenticateRequestProto.AuthenticateRequest.parseFrom(request.getBody());

    }
}
